
const request = require('request')

/**
 * @param {string} js_code
 * @returns
 */
export function code2Session(appid:string,secret:string,code:string):Promise<string>{
    let url = `https://api.weixin.qq.com/sns/jscode2session?appid=${appid}&secret=${secret}&js_code=${code}&grant_type=authorization_code`
    return new Promise(function(resolv,reject){
        request(url, (err,res,body)=>{
            resolv(body);
        })
    });
};